<?php


namespace App\Models;
use Carbon\Carbon;

use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;


/**
 * Class Admin
 *
 * @property int $id
 * @property string $name
 * @property string|null $avatar
 * @property string|null $nick_name
 * @property string $password
 * @property int|null $gid
 * @property string|null $phone
 * @property Carbon|null $last_login_time
 * @property string|null $last_login_ip
 * @property Carbon|null $create_at
 * @property Carbon|null $update_at
 * @property Carbon|null $delete_at
 *
 * @package App\Models
 */
class Admin extends Authenticatable
{

    use Page;


    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

	protected $table = 'zh_admin';

    const UPDATED_AT = 'update_at';

    const CREATED_AT = 'create_at';


	protected $hidden = [
		'password'
	];

	protected $fillable = [
		'name',
		'password',
        'avatar',
        'nick_name',
        'gid',
        'phone',
        'last_login_time',
        'last_login_ip',
        'remember_token',
        'create_at',
        'update_at',
        'delete_at'
	];

	protected $appends = ['gid_string'];

    /**
     * @return mixed
     */
	public function getGidStringAttribute()
    {
        return AdminGroup::whereKey($this->gid)->value('name');
    }

}
